<?php
/**
 * 
 * VView.php
 * @author noskill
 *
 */
/**
 * VView
 * 
 * @package View
 * @author mw
 *
 */
abstract class VView extends Smarty {
	/**
	 * 
	 * Layout di default
	 * @var string
	 */
	private static $default_layout = 'main.tpl';
	/**
	 * 
	 * Layout
	 * @var string $layout 
	 */
	protected $layout;
	/**
	 * Pagina
	 * @var string $page
	 */
	protected $page = 'empty.tpl';
	/**
	 * Costruttore
	 */
	public function __construct() {
		parent::__construct();
		
		$this->debugging = false;
		$this->caching = false;
		$this->cache_lifetime = 120;
		
		$this->template_dir = 'View/Templates/main';
		$this->cache_dir = 'View/Templates/cache';
		$this->compile_dir ='View/Templates/compile';
		$this->config_dir = 'View/Templates/config';

		
		$this->layout = self::$default_layout;
		
		/**
		 * Variabili utili a tutti gli script
		 */
		
		$creg = new CRegistrazione();
		$utente = $creg->getUtenteLoggato();
		
		if($utente != false){
			$this->assign('v_utente',$utente);
		}
		
		$admin = 0;
		if($utente != false && $utente->getLivello() == AMMINISTRATORE){
			$admin = 1;
		}
		
		
		$this->assign('v_admin',$admin);
		
	}
	/**
	 * display
	 */
	public function display() {
		$this->assign('page',$this->page);
		parent::display($this->layout);
	}
	/**
	 * setPage
	 * @param string $page
	 */
	final protected function setPage( $page ) {
		$this->page = $page;
	}
	/**
	 * Nome del layout
	 * @param string $name
	 */
	public static function setDefaultLayout($name) {
		self::$default_layout = $name;
	}
	
}